
CV.Tree.Drag.Element = new Class({
    Implements: [Options, Events],

    initialize: function(element, options) {
        this.element = document.id(element);
        this.setOptions(options);
    },
    getElement: function() {
        return this.element;
    },
    onleave: function() {
        this.where = 'notAllowed';
        CV.Tree.Drag.ghost.firstChild.className = 'cv-tree-ghost-icon cv-tree-ghost-' + this.where;
    },
    onenter: function() {
        this.where = 'inside';
        CV.Tree.Drag.ghost.firstChild.className = 'cv-tree-ghost-icon cv-tree-ghost-' + this.where;
    },
    beforeDrop: function() {
        if(this.options.beforeDrop) {
            this.options.beforeDrop.apply(this, [this.current, this.target, this.where]);
        }
        else {
            this.drop();
        }
    },
    drop: function() {
        CV.Tree.Drag.ghost.dispose();

        this.fireEvent('drop', CV.Tree.Drag.current);
    },
    getLevel: function() {
        var level = 0;
        var node = this;
        while(node){
            node = node.getParent();
            level++;
        }
        return level;
    }
});
